package com.example.aqarapp.viewmodel;

import android.util.Log;

import androidx.lifecycle.ViewModel;
import com.example.aqarapp.model.LoginModel;

import org.json.JSONException;
import org.json.JSONObject;

public class LoginViewModel extends ViewModel {
    private static final String TAG = "LoginViewModel";
    private String title = "欢迎使用智慧家庭";

    private LoginModel mLoginModel = new LoginModel();
    public LoginViewModel() {

    }

    public String getTitle() {
        return title;
    }

    public boolean Apare_login(String username, String pwd) {
        Log.d(TAG, "Apare_login: ");
        if(username.equals("1")) {
            if(pwd.equals("1")) {
                return true;
            }
            else {
                return false;
            }
        }
        else {
            return false;
        }
    }

    public boolean getAuthCode(String username) throws JSONException {
        Log.d(TAG, "getAuthCode: ");
        JSONObject loginRequest = new JSONObject();
        loginRequest.put("intent","config.auth.getAuthCode");
        JSONObject loginData = new JSONObject();
        loginData.put("account", username);
        loginData.put("accountType", 0);
        loginData.put("accessTokenValidity", "1h");
        loginRequest.put("data", loginData);
        return true;
    }

    public void getToken() {

    }
}
